package com.quasar.hpatient.presenter;

import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.litePalmodel.DailyItemInfodb;
import com.quasar.hpatient.model.medicalmodel.DailyRecordDetailsData;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OnDailyMoreListener;

import java.util.List;

/**
 * author : 许建宏
 * Date: 2017/11/24 0024
 * View: 日常记录更多
 */

public class DailyMorePresenter {

    private RequestModel requestModel;
    private OnDailyMoreListener onDailyMoreListener;


    public DailyMorePresenter(OnDailyMoreListener onDailyMoreListener) {
        this.requestModel = new RequestModel();
        this.onDailyMoreListener = onDailyMoreListener;
    }

    //查询数据库中的日常检查
    public void dailyMoreData(){
        requestModel.dailyMoreServer(new AnotherResultListener<List<DailyItemInfodb>>() {
            @Override
            public void onSuccess(List<DailyItemInfodb> data) {
                onDailyMoreListener.onSuccessSameday(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {

            }
        });
    }

    //日常数据更多提交
    public void moreAddDailyRecordData(String list,String startTime,String warn){
        requestModel.moreAddDailyRecordData(list, startTime,warn, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onDailyMoreListener.onSubmitSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }

    //新增日常检查项目
    public void addDailyItem(String dailyitemName,String dailyitemDose,String checkTime,String itemId){

        requestModel.AddDailyItem(dailyitemName, dailyitemDose, checkTime,itemId, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onDailyMoreListener.onItemSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }

    //删除item
    public void DeleteDailyItem(String id){

        requestModel.DeleteDailyItemData(id, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onDailyMoreListener.ondeleteSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }

    //查询当日检查记录
    public void GetPatientDailySingleRecords(String startTime){

        requestModel.GetPatientDailySingleRecordsData(startTime, new AnotherResultListener<AnotherResult<DailyRecordDetailsData>>() {
            @Override
            public void onSuccess(AnotherResult<DailyRecordDetailsData> data) {
                onDailyMoreListener.onDailyInspect(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }

    //查询日常记录item折线图
    public void LineGetUserAloneItemDailyRecord(String itemName,String startTime,String endTime){

        requestModel.GetUserAloneItemDailyRecordData(itemName, startTime, endTime, new AnotherResultListener<AnotherResult<DailyRecordDetailsData>>() {
            @Override
            public void onSuccess(AnotherResult<DailyRecordDetailsData> data) {
                onDailyMoreListener.onLineSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }

    //查询一天日常记录item折线图
    public void GetUserDailyRecord_AWeek2ServerData(String itemName,String startTime,String endTime){

        requestModel.GetUserDailyRecord_AWeek2Server(itemName, startTime, endTime, new AnotherResultListener<AnotherResult<DailyRecordDetailsData>>() {
            @Override
            public void onSuccess(AnotherResult<DailyRecordDetailsData> data) {
                onDailyMoreListener.onLineOneDaySuccess(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }

    //获取上一次日常记录信息
    public void lastDailyRecordListData(String toDay){

        requestModel.lastDailyRecordListData(toDay, new AnotherResultListener<AnotherResult<DailyRecordDetailsData>>() {
            @Override
            public void onSuccess(AnotherResult<DailyRecordDetailsData> data) {
                onDailyMoreListener.onLastOneDaySuccess(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }

    //获取下一次日常数据
    public void GetNextDailyRecordListData(String toDay){

        requestModel.GetNextDailyRecordListData(toDay, new AnotherResultListener<AnotherResult<DailyRecordDetailsData>>() {
            @Override
            public void onSuccess(AnotherResult<DailyRecordDetailsData> data) {
                onDailyMoreListener.onNextOneDaySuccess(data);
            }

            @Override
            public void onError(String msg) {
                onDailyMoreListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onDailyMoreListener.onRefreshUI();
            }
        });
    }


}
